package com.demo.webapp.filter;


import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.demo.core.model.Site;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper;

/**
 * MultisiteRequestWrapper
 * 多站点请求封装类<br>
 * 存储访问请求request和用户访问的主站点信息
 * 
 * @author ryuu.kk
 * @serial at 2013-04-06 新增基于Function模型的访问安全  by ryuu.kk
 */
public class MultisiteRequestWrapper extends HttpServletRequestWrapper {
	
	/**
	 * 日志
	 */
    private final transient Log log = LogFactory.getLog(MultisiteRequestWrapper.class);
    
    /**
     * 站点信息
     */
    private final Site preferredSite;

    
    /**
     * 设置用户访问的站点信息
     * @param decorated 当前请求
     * @param Site 当前站点信息
     */
	public MultisiteRequestWrapper(final HttpServletRequest decorated, final Site userSite) {
        super(decorated);
        preferredSite = userSite;
        if (null == preferredSite) {
            log.error("preferred site = null, it is an unexpected value!");
        }
    }

    public Site getSite() {
    	return this.preferredSite;
    }
}